﻿using Api1.Model;
using Api1.Service;
using System;
using System.Collections.Generic;

namespace Api1
{
    /// <summary>
    /// 闸机通用接口
    /// </summary>
    public class ApiService
    {
        /// <summary>
        /// 获取模板特征数据
        /// </summary>
        /// <param name="card_no">卡号</param>
        /// <param name="Data">模板特征数据</param>
        /// <param name="varify_type">类型 1 指纹 2人脸</param>
        public static void uploadModelData(String card_no,String datas,String score,String varify_type) {
             ApiServiceImpl.UploadModelData(card_no,datas,score,varify_type);
        }
        /// <summary>
        /// 获取验证码
        /// </summary>
        /// <param name="card_no"></param>
        /// <param name="brakemachine_no"></param>
        /// <param name="cabinet_no">柜号</param>
        /// <returns></returns>
        public static Dictionary<string, object> inSwipeCard(string card_no, string brakemachine_no,string cabinet_no)
        {
            return ApiServiceImpl.getCharacteristic( card_no, brakemachine_no,cabinet_no);
        }
        /// <summary>
        /// 出场刷卡
        /// </summary>
        /// <param name="card_no"></param>
        /// <param name="brakemachine_no"></param>
        /// <returns></returns>
        public static Dictionary<string, object> outSwipeCard(string card_no, string brakemachine_no, String cabinet_no,int is_store) {
            return ApiServiceImpl.outSwipeCard( card_no, brakemachine_no, cabinet_no, is_store);
        }
        /// <summary>
        /// 内门禁
        /// </summary>
        /// <param name="card_no"></param>
        /// <param name="brakemachine_no"></param>
        /// <returns></returns>
        public static Dictionary<string, object> innerDoorSwipe(String card_no, String brakemachine_no) {
              return   ApiServiceImpl.innerDoorSwipe( card_no,  brakemachine_no);
        }
        /// <summary>
        /// 生物识别验证回调用
        /// </summary>
        /// <param name="card_no"></param>
        /// <param name="flag"></param>
        /// <param name="brakemachine_no"></param>
        public static  Dictionary<string, object>  swipeFingerPrintResult(string card_no, bool flag, string brakemachine_no) {
           ApiServiceImpl.swipeFingerPrintResult(card_no, flag, brakemachine_no);

            if (flag)
            {
                Dictionary<String,Object> result=  ApiServiceImpl.inSwipeCard(card_no, brakemachine_no);
                //获取原卡号
                card_no = InterfaceService.GetInstance().GetOriginalCardNo(card_no);
                Interfaces interfaces = InterfaceService.GetInstance().FindByCardno(card_no);

                if (Convert.ToBoolean(result["flag"]) && interfaces.Owner_Type == 1) {
                    result["member"] = ApiServiceImpl.GetContractInfo(card_no);
                }
                return result;
            }
            else {
                return ApiServiceImpl.getResult(false,"",false);
            }
        }       
    }
}
